import { decorator } from "@/tools/fns"
import { observer } from "mobx-react"
import React from "react"
import { Controller } from "@/controller"
import * as apis from "@/apis"

/** 浏览器登录 */
const LoginBrowser = decorator(observer)(() => {

    React.useEffect(() => {
        const code = new URLSearchParams(window.location.search).get('code')
        if (!code) return
        apis.user.login.post(code).then(e => {
            Controller.instance.token = e.token
            Controller.instance.userInfo = e.userInfo
            window.sessionStorage.setItem('$$/token', e.token)
            window.sessionStorage.setItem('$$/user-info', JSON.stringify(e.userInfo))
        })
    }, [])

    return (
        <div>...</div>
    )
})
export default LoginBrowser;